package com.zff.rental.utils.sql.impl;

import com.zff.rental.utils.sql.Condition;
import com.zff.rental.utils.sql.ConditionConnector;
import com.zff.rental.utils.sql.WhereConditionConnector;
import com.zff.rental.utils.sql.WhereNext;

/**
 * @author HCY
 */
class WhereNextImpl extends SqlContextHolder implements WhereNext {
    public WhereNextImpl(SqlContext sqlContext) {
        super(sqlContext);
    }

    @Override
    public <T> WhereConditionConnector and(Condition<T> condition) {
        sqlContext.getConditionConnector().and(condition);
        return sqlContext.getWhereConditionConnector();
    }

    @Override
    public <T> ConditionConnector and(String condition) {
        sqlContext.getConditionConnector().and(condition);
        return sqlContext.getWhereConditionConnector();
    }

    @Override
    public <T> WhereConditionConnector or(Condition<T> condition) {
        sqlContext.getConditionConnector().or(condition);
        return sqlContext.getWhereConditionConnector();
    }

    @Override
    public <T> ConditionConnector or(String condition) {
        sqlContext.getConditionConnector().or(condition);
        return sqlContext.getWhereConditionConnector();
    }

    @Override
    public String generateSql() {
        return sqlContext.getEndSql().generateSql();
    }
}
